package 原型模式.客户类;

import java.io.IOException;

public class Client {
    public static void main(String[] args) throws CloneNotSupportedException, IOException, ClassNotFoundException {
        Address address = new Address("中国", "广东", "广州", "510000");
        Customer customer = new Customer(address);

        System.out.println("---------------------------------------------浅克隆方式克隆----------------------------------------------------------------");
        Customer customer1=customer.clone();
        Customer customer2=customer.clone();
        System.out.println("本体的hashcode:"+customer.hashCode()+"\t属性对象Address的hashcode:"+customer.getAddress().hashCode());
        System.out.println("克隆1号的hashcode:"+customer1.hashCode()+"\t属性对象Address的hashcode:"+customer1.getAddress().hashCode());
        System.out.println("克隆2号的hashcode:"+customer2.hashCode()+"\t属性对象Address的hashcode:"+customer2.getAddress().hashCode());

        System.out.println();
        System.out.println("---------------------------------------------深克隆方式克隆----------------------------------------------------------------");
        Customer customer3=customer.deepClone();
        Customer customer4=customer.deepClone();
        System.out.println("本体的hashcode:"+customer.hashCode()+"\t属性对象Address的hashcode:"+customer.getAddress().hashCode());
        System.out.println("克隆1号的hashcode:"+customer1.hashCode()+"\t属性对象Address的hashcode:"+customer3.getAddress().hashCode());
        System.out.println("克隆2号的hashcode:"+customer2.hashCode()+"\t属性对象Address的hashcode:"+customer4.getAddress().hashCode());
    }
}
